package com.go.where.manager.dao.system.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.go.where.manager.dao.impl.BaseDaoImpl;
import com.go.where.manager.dao.system.MenuDao;
import com.go.where.manager.pojo.user.Menu;

@Repository("menuDao")
public class MenuDaoImpl extends BaseDaoImpl<Menu> implements MenuDao {

	@Override
	protected String getNameSpace() {
		return "mybatis.xml.MenuMapper";
	}

	@Override
	public List<Menu> query1LevelMenu() {
		return this.getSqlSession().selectList(
				getNameSpace() + ".query1LevelMenu");
	}

	@Override
	public List<Menu> query2LevelMenu() {
		return this.getSqlSession().selectList(
				getNameSpace() + ".query2LevelMenu");
	}

	@Override
	public List<Menu> query3LevelMenu() {
		return this.getSqlSession().selectList(
				getNameSpace() + ".query3LevelMenu");
	}

	@Override
	public List<String> queryAll() {
		List<Menu> perList = this.getSqlSession().selectList(
				getNameSpace() + ".queryAll");
		List<String> reList = new ArrayList<String>();
		if (perList != null) {
			for (Menu p : perList) {
				reList.add(p.getMenuId());
			}
		}
		return reList;
	}

	@Override
	public List<String> queryByRoleId(String roleId) {
		// TODO Auto-generated method stub
		List<Menu> perList = this.getSqlSession().selectList(
				getNameSpace() + ".queryByRoleId", roleId);
		List<String> reList = new ArrayList<String>();
		if (perList != null) {
			for (Menu p : perList) {
				reList.add(p.getMenuId());
			}
		}
		return reList;
	}

	@Override
	public List<Menu> queryMenuList(List<String> menuIdList) {
		Menu m = new Menu();
		m.setMenuIdList(menuIdList);
		return getSqlSession().selectList(getNameSpace() + ".queryMenuList", m);
	}

}
